<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        #content,#box{
            width: 600px;
            height: 50px;
            line-height: 50px;
            border: 1px solid #000;
            font-size: 30px;
        }
    </style>
</head>
<body>
    <h1>JS 表单其他事件</h1>
    <hr>

    <h2>实时显示输入文本</h2>

    <input type="text" id="content">
    <br>
    <br>
    <br>
    <div id="box"></div>

    <script>
        var input = document.getElementById('content');
        var div = document.getElementById('box');

        // input.onchange = function (){
        //     div.innerHTML = input.value;
        // }

        // 兼容性处理
        input.oninput = demo;
        input.onpropertychange = demo;

        function demo(){
            div.innerHTML = input.value;
        }

        input.onselect = function (){
            alert('我被选了!!');
        }

    </script>
</body>
</html>